package com.googlecode.microanalyst.palette.model;

import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.swt.graphics.Image;

import com.googlecode.microanalyst.designer.model.AnalysisElement;
import com.googlecode.microanalyst.designer.model.property.PropertyHandler;
import com.googlecode.microanalyst.palette.i18n.PaletteMessages;

public class Dataset extends AnalysisElement {

	private static final long serialVersionUID = 1L;

	public static final String ICON_PATH = "icons/dataset16.gif";//$NON-NLS-1$

	public static final String OUTPUT = "out";

	public static Image ICON = createImage(Dataset.class, ICON_PATH);

	private String name;

	public Dataset() {
		size.width = -1;
		size.height = -1;
		this.name = generateName();
	}

	private String generateName() {
		return PaletteMessages.Palette_Tool_Dataset
				+ ("" + System.currentTimeMillis()).hashCode();
	}

	@Override
	public Image getIconImage() {
		return ICON;
	}

	@Override
	public Dimension getSize() {
		return new Dimension(size.width, size.height);
	}

	@Override
	public void setSize(Dimension size) {
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		String old = this.name;
		this.name = name;
		firePropertyChange(DatasetProperties.PROPERTY_NAME, old, name); 
	}

	@Override
	public String toString() {
		return PaletteMessages.Palette_Tool_Dataset;
	}

	@Override
	public Object clone() {
		return new Dataset();
	}

	@Override
	public PropertyHandler getPropertyHandler() {
		return new DatasetProperties(this);
	}

}
